package com.jiyun.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jiyun.mapper.ZlItempmMapper;
import com.jiyun.model.information.ZlItempm;
import com.jiyun.service.IZlItempmService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 
 * @since 2024-09-23
 */
@Service
public class ZlItempmServiceImpl extends ServiceImpl<ZlItempmMapper, ZlItempm> implements IZlItempmService {


    @Autowired
    private ZlItempmMapper zlItempmMapper;



    @Override
    public IPage<ZlItempm> findPage(Integer pn, Integer ps, ZlItempm zlItempm) {
        Page<ZlItempm> page = new Page<>(pn, ps);
        LambdaQueryWrapper<ZlItempm> wrapper = new LambdaQueryWrapper<>();
        if (zlItempm != null) {
            if (StringUtils.isNotBlank(zlItempm.getName())) {
                // 检查名称不为空且不全为空格
                wrapper.like(ZlItempm::getName, zlItempm.getName());
            }
            if (StringUtils.isNotBlank(zlItempm.getType())) {
                // 类型不为空
                wrapper.eq(ZlItempm::getType, zlItempm.getType());
            }
        }
        Page<ZlItempm> page1 = zlItempmMapper.selectPage(page, wrapper);
        return page1;
    }

//    @Override
//    public List<ZlItempm> findItempm(Integer id) {
//        return zlItempmMapper.findItempm(id);
//    }
}
